package com.example.discover.viewmodel

import com.example.featuresdk.model.Book
import com.example.featuresdk.vo.Status
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow

/**
 * State that is observed by UI, changes to State will be reflected in UI automatically
 */
data class BooksUiState (
    var status: Status = Status.Loading,
    var message: String? = null,
    val books: Flow<List<Book>> = emptyFlow()
    ){
    companion object{
        fun loading() = BooksUiState(Status.Loading)

        fun success(books: Flow<List<Book>>) = BooksUiState(Status.Success, books= books)

        fun error(message: String) = BooksUiState(Status.Error, message)
    }
}